<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        input {
            background-color: #008000;
        }
    </style>
    <script>

        window.onload = function () {

            let ins = document.getElementsByTagName("input");
            for (let i = 0; i < ins.length; i++) {
                ins[i].onfocus = function () {
                    ins[i].style.backgroundColor = "red"
                }
                ins[i].onblur = function () {
                    ins[i].style.backgroundColor = "#008000";
                }
            }

        }

    </script>
</head>
<body>

<label>
    <input type="text"><input type="text"><input type="text">
</label>
</body>
</html>